<script setup lang="ts">
import HomePanel from "./HomePanel.vue";
import useStore from "@/store/index";
import { useLazyData } from "@/utils/hooks";
const { home } = useStore();
const target= useLazyData(()=>{
  home.getHotList(); //不同调用的axios 传参过去
})
// const target = ref(null);
// onMounted(() => {
//   const { stop } = useIntersectionObserver(
//     target.value,
//     ([{ isIntersecting }]) => {
//       console.log("人气推荐", isIntersecting);
//       //  可见
//       if (isIntersecting) {
//         // 发请求
//         home.getHotList();
//         // 停止监听
//         stop();
//       }
//     }
//   );
// });
</script>

<template>
  <HomePanel title="人气推荐" subTitle="人气爆款 千玺推荐">
    <ul class="goods-list" ref="target">
      <li v-for="item in home.hotGoodList" :key="item.id">
        <RouterLink :to="'/goods/'+item.id">
          <!--  :src="item.picture" src换成  v-lazy -->
          <img v-lazy="item.picture" alt="" />
          <p class="name ellipsis">{{ item.title }}</p>
          <p class="price">{{ item.alt }}</p>
        </RouterLink>
      </li>
    </ul>
  </HomePanel>
</template>

<style lang="less" scoped>
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #fff;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>
